home *** CD-ROM | disk | FTP | other *** search
/ IRIS Performer 2.2 Friends Demo / SGI IRIS Performer 2.2 Friends Demo.iso / friends / technology_playgroup / unwinder / driver_api / read_uw.c < prev    next >
C/C++ Source or Header  |  1997-11-17  |  2KB  |  73 lines

  1. /**********************************************************************
  2.  * TECHNOLOGY PLAYGROUP INC.   http://this.is/tpg   email: tpg@this.is
  3.  **********************************************************************
  4.  *
  5.  * read_uw.c
  6.  *
  7.  * Version: 1.0
  8.  * Date: 17 nov 1997
  9.  *
  10.  * A simple test program for the UNWINDER dual joystick adapter, that
  11.  * uses uwbasic.c and uwbasic.h -- a simple API.
  12.  *
  13.  *
  14.  * This program is intended as a starting point for communicating
  15.  * with the UNWINDER, and not considered a finished product.
  16.  *
  17.  * To compile on systems runnnig IRIX 5.xx, you must define the OLD_TERMIO 
  18.  * variable in the Makefile.  IRIX 6.x use a newer termios structure to
  19.  * support baud rates greater than 38400, so you'll need to comment out
  20.  * this line.  Compiling on IRIX 5.xx, with the OLD_TERMIO will allow you
  21.  * to run under IRIX 5.xx or 6.xx, except you'll be limited to 38400 baud.
  22.  *
  23.  *
  24.  **********************************************************************
  25.  * Glenn Silver [Nov97] TPG            -  current implementation 
  26.  * Jonathan Franco [Aug97] InfoMediArt -  1st design & implementation  
  27.  **********************************************************************/
  28.  
  29.  
  30. #include "uwbasic.h" 
  31.  
  32. /* Main program loop -- there ain't much else */
  33. void main(void)
  34. {
  35.  
  36.   uwJoystick j1, j2;
  37.  
  38.   uwSetVerbose(1); /* Display debug information */
  39.   
  40.   /*   OpenPort commands (partial list - please see tech doc for more details)
  41.                     p     polled mode
  42.             n     normal out (not debug)
  43.             A     joystick 1 Digital Mode (use 'a' for analog)
  44.             b     joystick 2 Analog Mode  (use 'B' for digital)
  45.             X     not on-change mode (values always output even if no change)
  46.             3     poll joysticks 1 and 2 
  47.   */
  48.  
  49.   uwOpenPort("/dev/ttyd2", "pnAbX3");
  50.   
  51.   printf( "\nJOYSTICK VALUES\n");
  52.  
  53.   while(1) {
  54.  
  55.     /* uwPoll returns 1 if OK and 0 if error */
  56.     int b1 = uwPoll1(&j1); /* Poll joystick 1 */
  57.     int b2 = uwPoll2(&j2); /* Poll joystick 2 */
  58.  
  59.     /* Output joystick data to standard out */
  60.     printf("j1(%d)= ", b1); uwPrint(stdout, &j1); printf("  ");  
  61.     printf("j2(%d)= ", b2); uwPrint(stdout, &j2); printf("\n"); 
  62.  
  63.   }
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.